package com.example.tokentest.webcontroller;

import com.example.tokentest.config.component.PassToken;
import com.example.tokentest.redispackage.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * \* @author: wky
 * \* Date: 2022/10/09
 * \* Time: 10:12
 * \* To change this template use File | Settings | File Templates.
 * \* Description:LoginController
 * \
 */
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
public class LoginController {

    @Autowired
    RedisCache redisCache;

    @RequestMapping("/userLogin")
    private String userLogin() {
        redisCache.setCacheObject("token","123456789012345678901234567890",5, TimeUnit.MINUTES);
        return redisCache.getCacheObject("token");
    }

    @PassToken
    @RequestMapping("/test1")
    private String test1() {
        return "test1";
    }

    @RequestMapping("/test2")
    private String test2() {
        return "test2";
    }


}